#include<bits/stdc++.h>
#include<sys/types.h>
#include<unistd.h>
using namespace std;
//int g_val;
//int g_val_2 = 100;
//int main()
//{
//  static int cc = 5;
////printf("xxx = %s\n",getenv("xxx"));
// printf("code addr:%p\n",main);
// const char * str = "hello";
// printf("read only string addr:%p\n",str);
// cout << &g_val_2 << endl;
// cout << &g_val << endl;
// cout << &cc << endl;
// int *t = new int(1);
// cout << t << endl;
// cout << &str << endl;
//  return 0;
//}
int g_val = 100;
int main()
{
  pid_t id = fork();
  if(id == 0)
  {
    int cnt = 5;
    //child
    while(true)
    {
      printf("i am child,pid:%d,ppid:%d,g_val:%d,g_val:%p\n",getpid(),getppid(),g_val,&g_val);
      sleep(1);
      if(cnt) cnt--;
      else {
        g_val = 200;
      }
    }

  }
  else {
    //父
    //
      while(true) {
      printf("i am parent,pid:%d,ppid:%d,g_val:%d,g_val:%p\n",getpid(),getppid(),g_val,&g_val);
       sleep(1);
        }

  }
  return 0;
}


